翻訳と辞書
Words near each other
・ Dutch Mill
・ Dutch Mills Township, Washington County, Arkansas
・ Dutch Mills, Arkansas
・ Dutch missions to Edo
・ Dutch Mob
・ Dutch monarchs family tree
・ Dutch municipal elections, 2006
・ Dutch municipal elections, 2010
・ Dutch municipal elections, 2014
・ Dutch Museum Association
・ Dutch name
・ Dutch National Badminton Championships
・ Dutch National Ballet
・ Dutch National Cycle Routes
・ Dutch National Cyclo-cross Championships
Dutch national flag problem
・ Dutch National Opera
・ Dutch National Rapporteur on Trafficking in Human Beings and Sexual Violence against Children
・ Dutch National Road Race Championships
・ Dutch National Students Association
・ Dutch National Time Trial Championships
・ Dutch National Track Championships
・ Dutch National Track Championships – Women's individual pursuit
・ Dutch National Track Championships – Women's madison
・ Dutch National Track Championships – Women's omnium
・ Dutch National Track Championships – Women's points race
・ Dutch National Track Championships – Women's scratch
・ Dutch nationality law
・ Dutch Navy Museum
・ Dutch Neck Crossroads, Delaware


Dictionary Lists
翻訳と辞書 辞書検索 [ 開発暫定版 ]
スポンサード リンク

Dutch national flag problem : ウィキペディア英語版
Dutch national flag problem

The Dutch national flag problem (DNF)〔 is a computer science programming problem proposed by Edsger Dijkstra.〔In a chapter of his book ''A Discipline of Programming'' Prentice-Hall, 1976〕 The flag of the Netherlands consists of three colours: red, white and blue. Given balls of these three colours arranged randomly in a line (the actual number of balls does not matter), the task is to arrange them such that all balls of the same colour are together and their collective colour groups are in the correct order.
The solution to this problem is of interest for designing sorting algorithms. In particular, variants of the quicksort algorithm that must be robust to repeated elements need a three-way partitioning function that groups items less than a given key (red), equal to the key (white) and greater than the key (blue). Several solutions exist that have varying performance characteristics, tailored to sorting arrays with either small or large numbers of repeated elements.〔The latter case occurs in string sorting with multi-key quicksort. 〕
== The array case ==
This problem can also be viewed in terms of rearranging elements of an array.
Suppose each of the possible elements could be classified into exactly one of three categories (bottom, middle, and top).
For example, if all elements are in 0 ... 1, the bottom could be defined as elements in 0 ... 0.1 (not including 0.1), the middle as 0.1 ... 0.3 (not including 0.3)
and the top as 0.3 and greater. (The choice of these values illustrates that the categories need not be equal ranges). The problem is then to produce an array such that all "bottom" elements come before (have an index less than the index of) all "middle" elements, which come before all "top" elements.
One algorithm is to have the top group grow down from the top of the array, the bottom group grow up from the bottom, and keep the middle group just above the bottom. The algorithm indexes three locations, the bottom of the top group, the top of the bottom group, and the top of the middle group. Elements that are yet to be sorted fall between the middle and the top group. At each step, examine the element just above the middle. If it belongs to the top group, swap it with the element just below the top. If it belongs in the bottom, swap it with the element just above the bottom. If it is in the middle, leave it. Update the appropriate index. Complexity is Θ(n) moves and examinations.

抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)
ウィキペディアで「Dutch national flag problem」の詳細全文を読む



スポンサード リンク
翻訳と辞書 : 翻訳のためのインターネットリソース

Copyright(C) kotoba.ne.jp 1997-2016. All Rights Reserved.